<?php

namespace App\Http\Controllers\admin;

use App\Dao\OrdersDao;
use App\Services\Code;
use SimpleSoftwareIO\QrCode\Facades\QrCode;

class OrdersController extends BaseController
{
    public function orders()
    {
        if(getIsHasPage()){
            return Code::message('',200,OrdersDao::orders(request()->all()));
        }
        return view('admin.orders.orders');
    }

    public function send_orders()
    {
        if(isPost()){
            $params = request()->post();
            OrdersDao::send_orders($params);
            return Code::message('',200);
        }
        $info = OrdersDao::orders_info(['order_id'=>request('order_id')]);



        return view('admin.orders.send_orders',[
            'orders_id'=>request('orders_id'),
            'info'=>$info,
            'json_data'=>json_decode(json_decode($info['user_uplaod_info'],true),true)
        ]);
    }

    public function qr_code()
    {
        return QrCode::format('png')
            ->errorCorrection('L')
            ->margin(0.5)
            ->size(190)
            ->generate('http://eys.mogooyun.com/h5?orderNum='.request('order_code'));
    }

}
